/*
   File: SsoTokenServiceImpl.java
   Copyright 2004-2010 99Bill Corporation. All rights reserved.
   Created at   2011-8-31
   Author       zhe.yang
   Changed at   2011-8-31
 */

package com.bill99.golden.inf.sso.mdp.service;

import com.bill99.golden.inf.sso.mdp.SsoTokenService;
import com.bill99.golden.inf.sso.mdp.dto.CreateTokenRequestDto;
import com.bill99.golden.inf.sso.mdp.dto.DestroyTokenRequestDto;
import com.bill99.golden.inf.sso.mdp.dto.RefreshTokenTimeRequestDto;
import com.bill99.golden.inf.sso.mdp.dto.ValidateTokenRequestDto;
import com.bill99.golden.inf.sso.mdp.dto.ValidateTokenResponseDto;
import com.bill99.golden.inf.sso.service.TokenService;
import com.bill99.golden.inf.sso.util.Statistics;

/**
 * SSO服务实现类
 */
public class SsoTokenServiceImpl implements SsoTokenService {

	public String createToken(CreateTokenRequestDto r) {
		// TODO Auto-generated method stub
		long st = System.currentTimeMillis();
		String token = TokenService.createToken(r);
		long ed = System.currentTimeMillis();
		Statistics.addCreateLog(ed - st);
		return token;
	}

	public ValidateTokenResponseDto validateToken(ValidateTokenRequestDto r) {
		// TODO Auto-generated method stub
		long st = System.currentTimeMillis();
		ValidateTokenResponseDto rt = TokenService.validateToken(r);
		long ed = System.currentTimeMillis();
		Statistics.addValidateLog(ed - st);
		return rt;
	}

	public void destroyToken(DestroyTokenRequestDto r) {
		// TODO Auto-generated method stub
		long st = System.currentTimeMillis();
		TokenService.destroyToken(r);
		long ed = System.currentTimeMillis();
		Statistics.addDestroyLog(ed - st);
	}

	public void refreshTokenTime(RefreshTokenTimeRequestDto r) {
		// TODO Auto-generated method stub
		TokenService.refreshToken(r);
	}

}
